import 'package:flutter/material.dart';
import 'package:flutter_boost/boost_flutter_binding.dart';
import 'package:flutter_boost/flutter_boost_app.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hzcloud_flt/common/hz_loading/hz_loading_dialog.dart';
import 'package:hzcloud_flt/feature/router.dart';
import 'package:hzcloud_flt/feature/tabbar.dart';

void main() {
  ///这里的CustomFlutterBinding调用务必不可缺少，用于控制Boost状态的resume和pause
  CustomFlutterBinding();
  runApp(MyApp());
}
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}
class CustomFlutterBinding extends WidgetsFlutterBinding with BoostFlutterBinding {

}
Widget appBuilder(Widget home) {
  return ScreenUtilInit(builder: (){
    return MaterialApp(
      title: 'Flutter Demo',
      themeMode: ThemeMode.light,
      debugShowCheckedModeBanner: true,
      // debugShowMaterialGrid: true,
      // checkerboardOffscreenLayers: true,
      darkTheme: ThemeData(
        brightness: Brightness.dark,
        appBarTheme: AppBarTheme(
          color: Colors.black,
          elevation: 0,
          textTheme: TextTheme(
            headline6: TextStyle(
              color: Color(0xFFFFFFFF),
              fontWeight: FontWeight.w600,
              fontSize: 18,
            ),
          ),
        ),
        scaffoldBackgroundColor: Colors.black,
      ),
      theme: ThemeData(
        brightness: Brightness.light,
        accentColor: Color(0xFF1b69fd),
        appBarTheme: AppBarTheme(
          color: Colors.white,
          elevation: 0.5,
          textTheme: TextTheme(
            headline6: TextStyle(
              color: Color(0xFF333333),
              fontWeight: FontWeight.w600,
              fontSize: 18,
            ),
          ),
        ),
        scaffoldBackgroundColor: Colors.white,
      ),
      builder:HZLoadingDialog.init(),
      //设置App主题
      home: ScreenUtilInit(
        builder: () {
          return home;
        },
        designSize: Size(375, 667),
      ),
    );
  });
}
///创建一个自定义的Binding，继承和with的关系如下，里面什么都不用写
class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return FlutterBoostApp(
      HZRouter().routeFactory,
      appBuilder: appBuilder,
    );
  }
}
